<!DOCTYPE html>
<html lang="">
<head>
    <title>WebSocket Test</title>
    <script src="/js/sockjs.min.js"></script>
    <script src="/js/stomp.min.js"></script>
    <script type="text/javascript">
        let socket = new SockJS('/ws');
        let stompClient = Stomp.over(socket);

        stompClient.connect({}, function (frame) {
            stompClient.subscribe('/topic/greetings', function (greeting) {
                showGreeting(JSON.parse(greeting.body).content);
            });

            stompClient.send("/app/hello", {}, "World");
        });

        function showGreeting(message) {
            let response = document.getElementById('greeting');
            response.innerText = message;
        }
    </script>
</head>
<body>
<div id="greeting"></div>
</body>
</html>